<template>
  <!--

          描述：本月概括
      -->
  <div class="user">
    <!--搜索表单-->
    <div class="common-seach-wrap">
      <el-form size="small" :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="选择日期">
          <el-date-picker v-model="formInline.date" type="monthrange" range-separator="至" start-placeholder="开始月份"
            end-placeholder="结束月份">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
          <el-button type="primary" icon="el-icon-search" @click="onPush">导出</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!--内容-->
    <div class="product-content">
      <div class="table-wrap">
        <el-table size="small" :data="tableData" border style="width: 100%" v-loading="loading">
          <el-table-column prop="gap" label="日期"></el-table-column>
          <el-table-column prop="tnum" label="订单数量"></el-table-column>
          <el-table-column prop="amount" label="销售额"></el-table-column>
        </el-table>
      </div>
    </div>


  </div>
</template>

<script>
  import OrderApi from '@/api/order.js';
  export default {

    data() {
      return {
        /*是否加载完成*/
        loading: true,
        /*列表数据*/
        tableData: [],
        /*一页多少条*/
        pageSize: 15,
        /*一共多少条数据*/
        totalDataNumber: 0,
        /*当前是第几页*/
        curPage: 1,
        /*横向表单数据模型*/
        formInline: {
          date: ''
        },
        /*是否打开添加弹窗*/
        open_add: false,
        /*是否打开编辑弹窗*/
        open_edit: false,
        /*当前编辑的对象*/
        userModel: {},
      };
    },
    created() {
      /*获取列表*/
      this.getTableList();
    },
    methods: {
      /*选择第几页*/
      handleCurrentChange(val) {
        let self = this;
        self.curPage = val;
        self.loading = true;
        self.getTableList();
      },

      /*每页多少条*/
      handleSizeChange(val) {
        this.curPage = 1;
        this.pageSize = val;
        this.getTableList();
      },

      /*获取列表*/
      getTableList() {
        let self = this;
        let Params = self.formInline;
        Params.page = self.curPage;
        Params.list_rows = self.pageSize;
        OrderApi.getOrderNumMonth(Params, true)
          .then(data => {
            console.log(data);
            self.loading = false;
            self.tableData = data.data.info;
            //self.totalDataNumber = data.data.list.total;
          })
          .catch(error => {
            self.loading = false;
          });
      },

      /*搜索查询*/
      onSubmit() {
        let self = this;
        self.loading = true;
        let Params = self.formInline;
        self.getTableList();
      },
      onPush() {
        let self = this;
        let Params = self.formInline;
        Params.type = 3;
        OrderApi.salePush(Params, true)
          .then(data => {
            let path = data.data.path;
            window.location.href = path;
          })
          .catch(error => {
            self.loading = false;
          });
      },

    }
  };
</script>
<style></style>
